<?php
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
$aResult = $BigDaddyHistory->GetBooleanHistoryByTime($_REQUEST["ID"], $nStartTime, $sType, time(), true);
header('Content-Type: text/xml');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");

echo '<?xml version="1.0" encoding="UTF-8"?>
<data>';

$aDowntime = array(1, 0,-1,-2,-3);
$aDowntimeString = array("Uptime", "Unscheduled Downtime","Scheduled Downtime","Disabled","No Data");

for ($j=0; $j<count($aDowntime); $j++)
{
    if (is_array($aResult["valuechange"][$aDowntime[$j]]))
    {
        
    
        for ($i=0; $i<count($aResult["valuechange"][$aDowntime[$j]]); $i++)
        {
            if ($aResult["valuechange"][$aDowntime[$j]][$i]["start"]>0)
            {
            ?>
            
    <event 
        start="<?=get_time_str($aResult["valuechange"][$aDowntime[$j]][$i]["start"], "timeline");?>"
        end="<?=get_time_str($aResult["valuechange"][$aDowntime[$j]][$i+1]["end"], "timeline");?>"
        isDuration="true"
        title="<?=$aDowntimeString[$j];?>"
    >
    <?=$aDowntimeString[$j];?>. 
    </event>
            <?
            }
            $i=$i+1;
        }
        
    }
}
echo "</data>";
?>
